package physics;

import game.Universe;
import globals.GlobalObjects;
import physics.Collisions.Collision;
import viewControllers.PortalViewController;

public class PortalEntrance extends GameObject{
	
	String exitName; 
	PortalExit exit;


	public void setParameter(String name, String params[])
	{
		if (name.equals("exit")) {
			this.exitName = params[0];
		}
		
		super.setParameter(name,params);
	}
	
	
	public void impact(Collision c){
		switch (c.getType()){
			case PORTAL:
				//System.out.println("portal");
				
				//this.exists = false;
				break;
			case DEFAULT:
				break;
		}
	}
	
	@Override
	public void commit(){
		PortalViewController portalVC = new PortalViewController(this);
		this.setGraphicalObject(portalVC);
		Universe.addGameObject(this);
		exit = (PortalExit) GlobalObjects.getGameObject(exitName) ;
		super.commit();
	}

	public PortalExit getExit() {
		return exit;
	}

	public void setExitName(String exitName) {
		this.exitName = exitName;
	}

	public void setExit(PortalExit exit) {
		this.exit = exit;
	}

}
